# 导入flask类
from flask import Flask, request,jsonify
from werkzeug.routing import BaseConverter
from werkzeug.utils import secure_filename
import json

app = Flask(__name__)


@app.route("/")
def index():
    return f"<h1>参数传递</h1>"

@app.route('/divide/<int:x>/<int:y>')
def divide(x, y):
    try:
        result = x / y
        return f'Result: {result}'
    except ZeroDivisionError:
        return 'Error: Division by zero', 400


@app.errorhandler(404)
def not_found(error):
    return 'Page not found', 404
    


@app.before_request
def before_request():
    print('Before request')

@app.after_request
def after_request(response):
    print('After request')
    return response

@app.teardown_request
def teardown_request(exception):
    print('Teardown request')




if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)
